<?php

/**
 * GlDiscount filter form base class.
 *
 * @package    GREEN_LIGHT
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseGlDiscountFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'name'              => new sfWidgetFormFilterInput(),
      'value'             => new sfWidgetFormFilterInput(),
      'quantity'          => new sfWidgetFormFilterInput(),
      'quantity_per_user' => new sfWidgetFormFilterInput(),
      'date_from'         => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'date_to'           => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'is_active'         => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
    ));

    $this->setValidators(array(
      'name'              => new sfValidatorPass(array('required' => false)),
      'value'             => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'quantity'          => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'quantity_per_user' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'date_from'         => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDateTime(array('required' => false)))),
      'date_to'           => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDateTime(array('required' => false)))),
      'is_active'         => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
    ));

    $this->widgetSchema->setNameFormat('gl_discount_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'GlDiscount';
  }

  public function getFields()
  {
    return array(
      'discount_id'       => 'Number',
      'name'              => 'Text',
      'value'             => 'Number',
      'quantity'          => 'Number',
      'quantity_per_user' => 'Number',
      'date_from'         => 'Date',
      'date_to'           => 'Date',
      'is_active'         => 'Boolean',
    );
  }
}
